package com.ruiyangwang.ListenBook.viewObject;

import com.ruiyangwang.ListenBook.dataObject.AlbumDO;
import com.ruiyangwang.ListenBook.dataObject.TrackDo;
import lombok.Data;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @author syzygy
 * @date 2022/07/20 21:28
 **/
@Data
public class BindView {
    public BindView(UserV0 currentUser, AlbumDO albumDO, List<TrackDo> trackDoList) {
        this.currentUser = currentUser;
        this.aid = albumDO.aid;
        this.title = albumDO.title;

         this.trackList = trackDoList.stream().map(d -> new TrackView(d.tid, d.title)).collect(Collectors.toList());
    }

    public static class TrackView{
        public Integer tid;
        public String title;

        public TrackView(Integer tid, String title) {
            this.tid = tid;
            this.title = title;
        }
    }
    public UserV0 currentUser;
    public Integer aid;
    public String title;
    public List<TrackView> trackList;
}